 <template>
    <div>
        <el-form :inline="true" :model="rfiBaseForm" class="demo-form-inline" label-width="120px">
            <el-form-item label="采购组织*">
                <el-select v-model="rfiBaseForm.purOrgId" placeholder="请选择" @change="handleChange">
                    <el-option v-for="item in purOrgOptions" :key="item.id" :label="item.purOrgName" :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="采购组*:">
                <el-select v-model="rfiBaseForm.purGroupId" placeholder="请选择">
                    <el-option v-for="item in relationPurGroup" :key="item.id" :label="item.purGroupName" :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="标题*：">
                <el-input v-model="rfiBaseForm.title"></el-input>
            </el-form-item>
            <el-form-item label="类型：">
                <el-select v-model="rfiBaseForm.infoType" placeholder="请选择">
                    <el-option v-for="item in rfiTypeOptions" :key="item.code" :label="item.remarks" :value="item.code"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="反馈截止日期*：" prop="endTime">
                <el-date-picker v-model="rfiBaseForm.endTime"  type="date" placeholder="选择日期"
                    :picker-options="pickerOptions1">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="附件上传" >
                <el-upload
                class="upload-file"
                ref="upload"
                :action=actionUrl
                :data=otherData
                :limit="1"
                :on-success="uploadSuccess"         
                :file-list="fileList">
                <el-button slot="trigger" type="primary" :disabled=isEdit>选取文件</el-button>
                </el-upload>       
            </el-form-item>
            <!-- <el-form-item>
                <UE :v-model="defaultMsg" :config="config" id="ue1" ref="ue"></UE>
            </el-form-item> -->
            <!-- <el-form-item label="备注：" prop="description" class="w100">
                <UE :v-model="defaultMsg" :config="config" id="ue1" ref="ue"></UE>
            </el-form-item>  -->
            <!-- <el-row>   -->
                <!-- <el-form-item label="备注：" prop="rfiBaseForm.description" class="w100">
                    <UE :v-model="rfiBaseForm.description" :config="config" id="ue" ref="ue"></UE>
                </el-form-item>  -->
  

                <el-form-item label="备注：" prop="description" class="w100">
                    <UE v-model="rfiBaseForm.description" :config="config" ref="ue"></UE>
                </el-form-item> 
            <!-- </el-row> -->
            <!-- <el-row>
                <el-col :span="6">
                    <div class="grid-content">
                        <el-form-item label="采购组织">
                            <el-select v-model="rfiBaseForm.purOrgId" placeholder="请选择" @change="handleChange">
                                <el-option v-for="item in purOrgOptions" :key="item.id" :label="item.purOrgName" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="6">
                    <div class="grid-content">
                        <el-form-item label="采购组:">
                            <el-select v-model="rfiBaseForm.purGroupId" placeholder="请选择">
                                <el-option v-for="item in relationPurGroup" :key="item.id" :label="item.purGroupName" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="6">
                    <div class="grid-content">
                        <el-form-item label="标题*：">
                            <el-input v-model="rfiBaseForm.title"></el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <div class="grid-content">
                        <el-form-item label="类型：" :label-width="formLabelWidth">
                        <el-select v-model="rfiBaseForm.infoType" placeholder="请选择">
                            <el-option v-for="item in rfiTypeOptions" :key="item.code" :label="item.remarks" :value="item.code"></el-option>
                        </el-select>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="7">
                    <div class="grid-content">
                        <el-form-item label="反馈截止日期*：" prop="endTime">
                            <el-date-picker v-model="rfiBaseForm.endTime" align="right" type="date" placeholder="选择日期"
                                :picker-options="pickerOptions1">
                            </el-date-picker>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="10">
                    <div class="grid-content">
                        <el-form-item label="附件上传" >
                        <el-upload
                        class="upload-file"
                        ref="upload"
                        :action=actionUrl
                        :data=otherData
                        :limit="1"
                        :on-success="uploadSuccess"         
                        :file-list="fileList">
                        <el-button slot="trigger" type="primary" :disabled=isEdit>选取文件</el-button>
                        </el-upload>       
                    </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row> 
                <el-form-item>
                    <UE :v-model="defaultMsg" :config="config" id="ue1" ref="ue"></UE>
                </el-form-item>
            </el-row> -->
        </el-form>
    </div>
</template>
<script>
    import UE from '@/components/common/ue/ue.vue';
    export default {
        data() {
            return {
                actionUrl: this.lib.config.host.system + '/common/fileupload/upload',
                fileList: [],
                rfiTypeOptions: [],
                otherData: {
                    busAction: "busaction",
                    tableName: "table"
                },
                pickerOptions1: {
                    disabledDate(time) {
                        return time.getTime() < Date.now();
                    }
                },
                // 采购组织集合
                purOrgOptions:[],
                // 采购组集合
                relationPurGroup: [],
                rfiBaseForm: {
                    infoType: 'rfi2',
                    description :'',
                    attFileUrl : '',
                    attFileName : ''
                },
                formLabelWidth: '200px',
                defaultMsg: '',
                config: {
                    initialFrameWidth: 1430,
                    initialFrameHeight: 200,
                    enableAutoSave: false
                 }  
            };
        },
        props:['rfiBaseForm'],
        components: {
            UE,
        },
        mounted() {
            this.initData();
        },
        methods: {
            initData(){
                // 获取采购组织
                this.getSelectData('get', this.lib.config.host.masterData + '/system/purOrgMgt/purOrg/getPurOrgByUserId/' + this.getCurrUserId(), {}, 'id', 'purOrgName').then((data)=>{
                    this.purOrgOptions = data;
                });
                this.getDicData('RFI_TYPE').then((data)=>{
                    this.rfiTypeOptions = data;
                });
            },
            // 采购组织在改变的时候查询采购组
            handleChange(value) {
                // 获取srm采购组
                this.getSelectData('post', this.lib.config.host.masterData + '/mdata/purOrgMgt/purGroup/getByPurOrgId/' + value, {}, 'id', 'purGroupName').then((data)=>{
                    this.relationPurGroup = data;
                });
            },
            uploadSuccess: function (response) {
                //附件上传成功回调
                this.rfiBaseForm.attFileUrl = response.url;
                this.rfiBaseForm.attFileName = response.fileName
            }
        }
  };
</script>
<style>
    .upload-file{
        display: flex;
        flex-direction: row-reverse;
        height: 40px;
        width: 380px;
    }

    .upload-file .el-upload-list {
        display: flex;
        flex-direction: row;
        width: calc(100% - 112px);
        border: 1px solid #dcdfe6;
        margin-right: 16px;
        border-radius: 4px;
    }

    .upload-file .el-upload-list li{
        margin-top: 0;
        line-height: 38px;
        vertical-align: middle;
    }

    .upload-file .el-upload-list li .el-icon-close{
        line-height: inherit;
        top:0;
    }
</style>